// This File the Basic Event Study Analysis (Table 2 - Panel A)
//"Effects of Credit Supply on Stock Market Booms and Busts"
// by Hansman, Hong, Jiang, Liu, and Meng
// Created: 09/25/2024 

// -----------------------------------------------------------------------------
// Set-Up
// -----------------------------------------------------------------------------
clear
eststo clear


// -----------------------------------------------------------------------------
// Loading Data
// -----------------------------------------------------------------------------
use ../dta/event_study_data.dta, replace


// -----------------------------------------------------------------------------
// Event Studies from Time 0
// -----------------------------------------------------------------------------
// 0 - 1
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==0 & months_relative_to_baseline==1  , cl(code) 
eststo es_1

// 0 - 3
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==0 & months_relative_to_baseline==3 , cl(code) 
eststo es_2

// 0 - 12
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==0 & months_relative_to_baseline==12 , cl(code) 
eststo es_3


// -----------------------------------------------------------------------------
// Event Studies from Lags
// -----------------------------------------------------------------------------
// 1 - 0
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==1 & months_relative_to_baseline==1 , cl(code) 
eststo es_4

// 3 - 0
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==3 & months_relative_to_baseline==3 , cl(code) 
eststo es_5

// 12 - 0
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==12 & months_relative_to_baseline==12 , cl(code) 
eststo es_6

// 12 - 12
reg car_ret_dgtw anyvintage i.rd_group if baseline_month==12 & months_relative_to_baseline==24 , cl(code) 
eststo es_7


esttab  es_1 es_2 es_3 es_4 es_5 es_6 es_7 ///
    using ../esttab/event_study.tex, replace ///
    stats( N, fmt(a3) labels( "N")  layout( "\multicolumn{1}{c}{@}" ) ) ///
    b(3) se(3)  booktabs compress  alignment(D{.}{.}{-1}) ///
    keep(anyvintage) order(anyvintage) l  wrap  varwidth(30) frag  nomtitles ///
    nonumbers  noobs nonotes ///
    star(* 0.10 ** 0.05 *** .01)
